<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
  <title>新闻资讯</title>
</head>
<include file="style"/>
<style type="text/css">

.text-line {
  border-top: 1px solid #909090; 
  width: 50px; 
  display: inline-block; 
  vertical-align: 5px;
}


.sub-title-div {
  text-align: center;
}

.sub-title-text {
  font-size: 20px;
  color: #00A0EA;
}

.sub-title-text-eng {
  font-size: 18px;
  color: #909090;
}


.news-title-div {
  width: 64%;
  margin: 0px auto;
}

.divider-border:not(:last-child) {
  border-bottom: 1px dashed #E5E5E5;
}

.news-title-ceil-box {
  padding: 30px 0;
}



</style>
<body>

<include file="header"/>


<div id="newsContentDiv">

<div style="width: 100%; height: 580px; background-image: url('{$banner}'); background-repeat: no-repeat; background-size: 100% 100%;">
</div>

  <div class="sub-title-div" style="margin-top: 30px;">
    <div class="sub-title-text">新闻资讯</div>
    <div>
      <span class="text-line"></span>
      <span class="sub-title-text-eng">News</span>
      <span class="text-line"></span>
    </div>
  </div>

  <div class="news-title-div wow bounceIn">
    <div class="am-g divider-border news-title-ceil-box" v-for="n in news">
      <div class="am-u-lg-1 am-u-md-2 clear-margin-padding">
        <div style="font-size: 30px; font-weight: 70; color: #000000;">{{n.day}}</div>
        <div style="font-size: 16px; margin-top: -10px;">{{n.year}}</div>
      </div>
      <div class="am-u-lg-11 am-u-md-10 clear-margin-padding">
        <div style="font-size: 20px; font-weight: 60; color: #666666; cursor: pointer;" @click="clickNewsTitle(n.id)">{{n.title}}</div>
        <div style="font-size: 15px; color: #666666; margin-top: 8px;">
          {{n.description}}
        </div>
      </div>
    </div>
  
  </div>

  <ul class="am-pagination am-pagination-default" style="text-align: center;">
      
      <li>
        <button type="button" class="am-btn am-btn-primary" v-bind:disabled="isNotHavaPrePage" @click="clickPrePage">上一页</button>
      </li>

      <li class="">
        <div style="padding: 0 15px;">{{currentPage}}/{{totlePage}}</div>
      </li>

      <li>
        <button type="button" class="am-btn am-btn-primary" v-bind:disabled="isNotHaveNextPage" @click="clickNextPage">下一页</button>
      </li>

  </ul>
</div>


<include file="footer"/>
</body>

<!-- <script src="__PUBLIC__/js/vue.min.js"></script> -->
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script type="text/javascript">

new WOW().init()

new Vue({
  el: "#newsContentDiv",
  data: {
    currentPage: 1,
    totlePage: 0,
    isNotHavaPrePage: false,
    isNotHaveNextPage: false,
    news: new Object(),
  },
  mounted: function() {
    this.getTotlePage()
    // this.refreshNews()
  },
  methods: {
    refreshNews: function() {
      let that = this
      axios.get(`/index.php/Index/getNewsPerPage?current=${this.currentPage}`)
        .then(function(response) {
          that.news = response.data
          that.isNotHavaPrePage = that.currentPage === 1
          that.isNotHaveNextPage = that.currentPage === that.totlePage
          // console.log(response.data)
        })
    },

    getTotlePage: function() {
      let that = this
      axios.get('/index.php/Index/getNewsTotlePageNum')
        .then(function(response) {
          // console.log(response)
          that.totlePage = response.data.pageNum
          that.refreshNews()
        })
    },

    clickNextPage: function() {
      this.currentPage = this.currentPage + 1
      this.refreshNews()
    },

    clickPrePage: function() {
      this.currentPage = this.currentPage - 1
      this.refreshNews()
    },

    clickNewsTitle: function(id) {
      window.location.href = `/index.php/Index/newsPage?id=${id}`
    }

  }
})

</script>
</html>